package com.storage;

import com.storage.client.StorageClient;
import com.storage.configuration.StorageConfiguration;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * 存储模板
 */
@Getter
@Setter
public class StorageTemplate {

    private List<List<? extends StorageClient>> storageClientList;

    private StorageConfiguration configuration;

    /**
     * 获取存储客户端
     * @param client
     * @return
     */
    public StorageClient getStorageClient(String client) {
        for (List<? extends StorageClient> storageClients : storageClientList) {
            for (StorageClient storageClient : storageClients) {
                if (storageClient.getClient().equals(client)) {
                    return storageClient;
                }
            }
        }
        return null;
    }

    /**
     * 获取默认存储客户端
     * @return
     */
    public StorageClient getDefaultStorageClient() {
        return getStorageClient(configuration.getDefaultClient());
    }


}
